<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="org.jeecgframework.core.util.SysThemesUtil,org.jeecgframework.core.enums.SysThemesEnum"%>
<%@include file="/context/mytags.jsp"%>
<%
    session.setAttribute("lang","zh-cn");
    SysThemesEnum sysTheme = SysThemesUtil.getSysTheme(request);
    String lhgdialogTheme = SysThemesUtil.getLhgdialogTheme(sysTheme);
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta charset="utf-8" />
    <title>新疆焦煤集团</title>
    <link rel="shortcut icon" href="images/newlog.png">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

    <link href="plug-in/loginnew/css/login.css" rel="stylesheet" rev="stylesheet" type="text/css" media="all" />
    <link href="plug-in/loginnew/login/css/demo.css" rel="stylesheet" rev="stylesheet" type="text/css" media="all" />
    <script src="plug-in/ace/js/ace-extra.js"></script>
    <script>
        $(function(){

            $(".i-text").focus(function(){
                $(this).addClass('h-light');
            });

            $(".i-text").focusout(function(){
                $(this).removeClass('h-light');
            });






            $("#yzm").focus(function(){
                var username = $(this).val();
                if(username=='输入验证码'){
                    $(this).val('');
                }
            });

            $("#yzm").focusout(function(){
                var username = $(this).val();
                if(username==''){
                    $(this).val('输入验证码');
                }
            });





        });




    </script>


</head>

<body class="login-layout light-login">

<div class="header">
    <h1 class="headerLogo"><a title="新疆焦煤集团" target="_blank" href="#">新疆焦煤集团数据上传系统</a></h1>
    <div class="headerNav">

        <a target="_blank" href="#"></a>
    </div>
</div>

<div class="banner">

    <div class="login-aside">
        <div id="o-box-up"></div>
        <div id="o-box-down"  style="table-layout:fixed;">
            <div class="error-box"></div>

            <form id="loinForm" name="loinForm" class="form-horizontal"  check="loginController.do?checkuser"  role="form" action="loginController.do?login"  method="post">
               <input type="hidden" name="scrwidth" id="scrwidth"/>
                <input type="hidden" name="scrhight" id="scrhight"/>
                <input type="hidden" name="windowhight" id="windowhight"/>
                <div class="fm-item">
                     <label for="logonId" class="form-label">用户登录</label>
                    <span class="block input-icon input-icon-right">
                    <input type="text"  name="userName" class="form-control i-text" placeholder="请输入用户名"  id="userName"datatype="s6-18" value="admin"/>
                  <%--  <input type="text" value=""placeholder="请输入帐号" maxlength="100" id="userName" class="i-text" ajaxurl="demo/valid.jsp"  datatype="s6-18" errormsg="用户名至少6个字符,最多18个字符！"  >--%>
                    <i class="ace-icon fa fa-user"></i>
                   <span>
                </div>

                <div class="fm-item">
                    <label for="logonId" class="form-label"></label>
                    <span class="block input-icon input-icon-right">
						<input type="password" name="password" class="form-control i-text" placeholder="请输入密码" id="password" value="123456"/>
						<i class="ace-icon fa fa-lock"></i>
					</span>
<%--                    <input type="password" value=""  placeholder="请输入密码" maxlength="100" id="password" class="i-text" datatype="*6-16" nullmsg="请设置密码！" errormsg="密码范围在6~16位之间！">
                    <div class="ui-form-explain"></div>--%>
                </div>

                <div class="fm-item pos-r">
                    <label for="logonId" class="form-label"></label>
  <%--                  <div class="input-group">
                        <input type="text" style="width:150px" name="randCode" class="form-control i-text yzm" placeholder="请输入验证码"  id="randCode"/>
                        <span class="input-group-addon" style="padding: 0px;"><img id="randCodeImage" src="randCodeImage"  /></span>
                    </div>--%>

                    <input type="text"  maxlength="100" name="randCode" id="randCode" class="i-text yzm" nullmsg="请输入验证码！"placeholder="请输入验证码" >
                    <div class="ui-form-explain"><img id="randCodeImage" src="randCodeImage" class="yzm-img"/></div>
                </div>

                <div class="fm-item">
                    <label for="logonId" class="form-label"></label>
                                       <div class="space"></div>
                      <div class="clearfix">
                        <label class="inline">
                          <input type="checkbox" class="ace" id="on_off"  name="remember" value="yes"/>
                          <span class="lbl">记住用户名</span>
                        </label>

                      </div>
                      <div class="space-4"></div>

                    <button type="button" id="but_login"  onclick="checkUser()" abindex="4" class="width-35 pull-right btn btn-lg btn-primary btn-login">
                        <i class="ace-icon fa fa-key"></i>
                        <span class="bigger-110" >登录</span>
                    </button>

                    <div class="ui-form-explain"></div>
                </div>
                <div class="toolbar clearfix">
<%--                    <div style="float: right">
                        <a href="#"  class="forgot-password-link">
                            语言
                            <i class="ace-icon fa fa-arrow-right"></i>
                            <t:dictSelect id="langCode" field="langCode" typeGroupCode="lang" hasLabel="false" extendJson="{style:'padding:2px; width:80px;'}" defaultVal="zh-cn"></t:dictSelect>
                        </a>
                    </div>--%>
                </div>
            </form>

        </div>

    </div>

    <div class="bd">
        <ul>
            <li style="background:url(plug-in/loginnew/themes/login_tk.jpg) #CCE1F3 center 0 no-repeat;height: 700px"><%--<a target="_blank" href="#"></a>--%></li>

        </ul>
    </div>

    <div class="hd"><ul></ul></div>
</div>
<script type="text/javascript">
    jQuery(".banner").slide({ titCell:".hd ul", mainCell:".bd ul", effect:"fold",  autoPlay:true, autoPage:true, trigger:"click" });</script>


<div class="banner-shadow"></div>

<div class="footer">
    <p>Copyright &copy; 2017.宝信软件股份有限公司.<a target="_blank" href="http://www.baosight.com/"></a></p>
</div>


<script type="text/javascript" src="plug-in/jquery/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="plug-in/jquery/jquery.cookie.js"></script>
<script type="text/javascript" src="plug-in/mutiLang/en.js"></script>
<script type="text/javascript" src="plug-in/mutiLang/zh-cn.js"></script>
<script type="text/javascript" src="plug-in/login/js/jquery.tipsy.js"></script>
<script type="text/javascript" src="plug-in/login/js/iphone.check.js"></script>
<script type="text/javascript" src="plug-in/login/js/login.js"></script>
<script type="text/javascript">
    $(function(){
        loinForm.scrwidth.value = screen.width;
        loinForm.scrhight.value = screen.height;
        loinForm.windowhight.value = screen.availHeight;


        $.get("loginController.do?getRandCode", function(result){

            $("#randCode").val(result);
        },"json");
        optErrMsg();
    });
    $("#errMsgContiner").hide();
    function optErrMsg(){
        $("#showErrMsg").html('');
        $("#errMsgContiner").hide();
    }

    //输入验证码，回车登录
    $(document).keydown(function(e){
        if(e.keyCode == 13) {
            $("#but_login").click();
        }
    });

    //验证用户信息
    function checkUser(){
        if(!validForm()){
            return false;
        }
        newLogin();
    }
    //表单验证
    function validForm(){
        if($.trim($("#userName").val()).length==0){
            showErrorMsg("请输入用户名");
            return false;
        }

        if($.trim($("#password").val()).length==0){
            showErrorMsg("请输入密码");
            return false;
        }

        if($.trim($("#randCode").val()).length==0){
            showErrorMsg("请输入验证码");
            return false;
        }
        return true;
    }

    //登录处理函数
    function newLogin(orgId) {
        setCookie();
        var actionurl=$('form').attr('action');//提交路径
        var checkurl=$('form').attr('check');//验证路径
        var formData = new Object();
        var data=$(":input").each(function() {

            formData[this.name] =$("#"+this.name ).val();

        });
        formData['orgId'] = orgId ? orgId : "";
        //语言
/*        formData['langCode']=$("#langCode").val();
        formData['langCode'] = $("#langCode option:selected").val();*/

        formData['langCode']="zh-cn";
        $.ajax({
            async : false,
            cache : false,
            type : 'POST',
            url : checkurl,// 请求的action路径
            data : formData,
            error : function() {// 请求失败处理函数
            },
            success : function(data) {
                var d = $.parseJSON(data);
                if (d.success) {
                    if (d.attributes.orgNum > 1) {
                        //用户拥有多个部门，需选择部门进行登录
                        var title, okButton;
                        if($("#langCode").val() == 'en') {
                            title = "Please select Org";
                            okButton = "Ok";
                        } else {
                            title = "请选择组织机构";
                            okButton = "确定";
                        }
                        $.dialog({
                            id: 'LHG1976D',
                            title: title,
                            max: false,
                            min: false,
                            drag: false,
                            resize: false,
                            content: 'url:userController.do?userOrgSelect&userId=' + d.attributes.user.id,
                            lock:true,
                            button : [ {
                                name : okButton,
                                focus : true,
                                callback : function() {
                                    iframe = this.iframe.contentWindow;
                                    var orgId = $('#orgId', iframe.document).val();

                                    formData['orgId'] = orgId ? orgId : "";
                                    $.ajax({
                                        async : false,
                                        cache : false,
                                        type : 'POST',
                                        url : 'loginController.do?changeDefaultOrg',// 请求的action路径
                                        data : formData,
                                        error : function() {// 请求失败处理函数
                                        },
                                        success : function(data) {
                                            window.location.href = actionurl;
                                        }
                                    });

                                    this.close();
                                    return false;
                                }
                            }],
                            close: function(){
                                setTimeout("window.location.href='"+actionurl+"'", 10);
                            }
                        });
                    } else {
                        window.location.href = actionurl;
                    }
                } else {
                    showErrorMsg(d.msg);

                    if(d.msg === "用户名或密码错误" || d.msg === "验证码错误")
                        reloadRandCodeImage();

                }
            }
        });
    }
    //登录提示消息显示
    function showErrorMsg(msg){
        $("#errMsgContiner").show();
        $("#showErrMsg").html(msg);
        window.setTimeout(optErrMsg,3000);
    }
    /**
     * 刷新验证码
     */
    $('#randCodeImage').click(function(){
        reloadRandCodeImage();
    });
    function reloadRandCodeImage() {
        var date = new Date();
        var img = document.getElementById("randCodeImage");
        //   img.src='randCodeImage';
      img.src='randCodeImage?a=' + date.getTime();
        $.get("loginController.do?getRandCode", function(result){
            $("#randCode").val(result);
        },"json");


        console.log("randcodeImage:"+date.getTime());
    }
/*    $.get("loginController.do?getRandCode", function(result){
        alert(1);
        $("#randCode").val(result)
    },"text");*/

    //设置cookie
    function setCookie()
    {
        if ($('#on_off').val() == '1') {
            $("input[iscookie='true']").each(function() {
                $.cookie(this.name, $("#"+this.name).val(), "/",24);
                $.cookie("COOKIE_NAME","true", "/",24);
            });
        } else {
            $("input[iscookie='true']").each(function() {
                $.cookie(this.name,null);
                $.cookie("COOKIE_NAME",null);
            });
        }
    }
    //读取cookie
    function getCookie()
    {
        var COOKIE_NAME=$.cookie("COOKIE_NAME");
        if (COOKIE_NAME !=null) {
            $("input[iscookie='true']").each(function() {
                $($("#"+this.name).val( $.cookie(this.name)));
                if("admin" == $.cookie(this.name)) {
                    $("#randCode").focus();
                } else {
                    $("#password").val("");
                    $("#password").focus();
                }
            });
            $("#on_off").attr("checked", true);
            $("#on_off").val("1");
        }
        else
        {
            $("#on_off").attr("checked", false);
            $("#on_off").val("0");
            $("#randCode").focus();
        }
    }
</script>
<%=lhgdialogTheme %>
</body>
</html>



